/**
 * @properties={typeid:24,uuid:"C3C9EB2B-BB92-4C16-A2C5-03795EDBBD53"}
 * @AllowToRunInFind
 */
function validar() {
	controller.setSelectedIndex(1)
	if (globals.gEstadoAbm == 1)
	{
		var $sql = 'SELECT centro_id FROM centro WHERE codigo = ? AND empresa = ?'
		var $args = [codigo, globals.gUservID]
		var $ds = databaseManager.getDataSetByQuery('contable',$sql,$args,-1)
		if ($ds.getMaxRowIndex() != 0) 
		{		
			return [false, false, "El código ingresado ya existe"]
		}
	}
	return [true]
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"F2086B88-234D-4107-BFC0-B28BA263FEC3"}
 */
function onShow(firstShow, event) {
	controller.sort("codigo asc")
}

/**
 * @properties={typeid:24,uuid:"97A45A8A-8026-4433-821D-0C3DF82772BC"}
 */
function imprimir() {
	jasper('impresion')
	//forms.centro_impresion.controller.showPrintPreview()
}

/**
 * @properties={typeid:24,uuid:"A17C627C-5BB6-4D46-A939-38B0BD27CFC3"}
 */
function pdf() {
	jasper('pdf')
	//globals.metodoPdf('centro_impresion','centro - '+globals.glegajo,true)
}

/**
 * @properties={typeid:24,uuid:"3B6DB7EF-C0F6-4FE8-87FA-A230BA906F1C"}
 */
function xls()
{
	jasper('xls')
}

/**
 * @properties={typeid:24,uuid:"2902735B-A77D-4AC9-BA59-DF8EFABD195F"}
 */
function csv()
{
	jasper('csv')
}

/**
 * @param {String} tipo
 * @properties={typeid:24,uuid:"CFD545E2-A5BC-4001-9961-015C63AEF7AB"}
 */
function jasper(tipo)
{
	var $params = {
		userv: usuarios_to_uservs.razon_social
	}
	
	globals.metodoJasper(tipo,'contable/centros.jasper','Centros',foundset,$params)
}
